<template>
	<view>
		<web-view :src="src" @load="bindload"></web-view>
		<!-- <web-view src="https://yludj.xetsl.com/s/1bCH1b" @load="bindload"></web-view> -->
	</view>
</template>

<script>
import { objectToRouteParams } from '@/common/util/util'
export default {
	data() {
		return {
			src: ''
		}
	},
	onLoad(option) {
		const token = uni.getStorageSync('Access-Token')
		if(!token){
			let pages = getCurrentPages()
			const backRoute = pages.length && pages[pages.length - 1]
			if(Object.keys(backRoute)){
				const options = backRoute.options || {}
				const query = objectToRouteParams(options)
				const url = Object.keys(options).length ? `/${backRoute.route}?${query}` : `/${backRoute.route}`
				uni.setStorageSync('origin', url)
			}

			uni.showLoading({})
			setTimeout(function() {
				uni.redirectTo({
					url: '/pages/login/login?path=',
					complete() {
						console.log('完成跳转')
						uni.hideLoading()
					}
				});
			}, 200)
			return
		}
		const distinctID = wx.sensors.getAnonymousID()
		if (process.env.NODE_ENV == 'development') {
			this.src = 'https://bjielts-t.test.xdf.cn/read?u2at='
			// this.src = 'http://10.176.138.77:5173/read?u2at='
		} else {
			this.src = 'https://bjielts.xdf.cn/read?u2at='
		}
		this.src =
			this.src +
			token +
			'&t=' +
			new Date().getTime() +
			`&distinctID=${distinctID}&readType=${option.readType}`
		console.log(this.src)
	},
	methods: {
		bindload() {}
	}
}
</script>

<style scoped></style>
